﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using SubsidyApp.Models;

namespace SubsidyApp.Models
{
    public class UsersRepository
    {
        public IQueryable<site_user> GetAllUsers()
        {
            return BasesDescription.db.site_users;
        }

        public void Add(site_user user)
        {
            BasesDescription.db.site_users.InsertOnSubmit(user);
            BasesDescription.Save();
        }

        public site_user GetUser(string login)
        {
            return BasesDescription.db.site_users.SingleOrDefault(u => u.user_login == login);
        }

        public site_user GetUser(int id)
        {
            return BasesDescription.db.site_users.SingleOrDefault(u => u.id == id);
        }

        public site_user GetUserByEmail(string email)
        {
            return BasesDescription.db.site_users.SingleOrDefault(u => u.user_email == email);
        }
    }
}